<script>
import * as utils from './utils/index'
export default {
    name: 'AppForm',
    componentName: 'AppForm',
    props: {
        options: {
            type: Object,
            default() =>{}
      },
result: {
    type: Object,
    default () => { }
}
    },
methods: {
    getDataMap() {
        return utils.makeResult(this.result, this.dataMap)
    }
},
render(h, ctx) {
    this.$set(this, 'dataMap', {})
    if (Object.keys(this.options.properties || {}).length === 0 && Object.keys(this.options.events || {}).length === 0) {
        const props = {
            props: {
                title: '无数据',
                type: 'info'
            }
        }
        return (<el-alert { ...props }></el-alert>)
    }
    const result = utils.initProperties(this.options, this.result)
    this.dataMap = Object.assign({}, this.dataMap, utils.deepCopy(result._result))
    const childrens = utils.makeRender(result.config, this.dataMap, h)
    const formConfig = {
        ref: 'dynamicValidateForm'
    }
    return (<el-form { ...formConfig } labelPosition="top">{childrens} </el-form>)
},
mapComponents: {
    Form, Alert
}
  }
</script>
